<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../../Css/style.css" />
    <script type="text/javascript" src="../../Js/jquery-2.1.4.min.js"></script>
    <script type="text/javascript" src="../../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../../Js/ckform.js"></script>
    <script type="text/javascript" src="../../Js/common.js"></script>
	<script type="text/javascript" src="../../myjQuery/jQuery-getUrlParam.js"></script>
    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }
    </style>
    
	<script>
    $(function(){
		$('#backid').click(function(){
				window.location.href="index.html";
		 });
    });
	$(function(){
		$('#commoditiesSave').click(function(){
			var commoditiesString = $('#claname').val()+'-'+
			$('#coid').val()+'-'+
			$('#coname').val()+'-'+
			$('#cophoto').val()+'-'+
			$('#conum').val()+'-'+
			$('#coprice').val()+'-'+
			$('#uid').val();
			//修改商品信息
			$.ajax({
				type:"post",
				url:"../../commdidties/comoditiesupdata?commoditiesString="+commoditiesString,
				contentType:"application/json;charset=utf-8",
				success:function(i){
					if(i == "1"){
						alert("修改成功");
					}else{
						alert("修改失败");
						}
				}
					});
		});
	});
	  $(function(){
		  var coid = $.getUrlParam('coid');
		  		//获取商品信息
				$.ajax({
					type:"post",
					url:"../../commdidties/findcoid?coid="+coid,
					contentType:"application/json;charset=utf-8",
					success:function(commodities){
						for(var i=0;i<commodities.length;i++ ){
							$('#claname').html("");
							$('#claname').append("<option value="+commodities[i].claname+">"+commodities[i].claname+"</option>");
							$('#coid').val(commodities[i].coid);
							$('#coname').val(commodities[i].coname);
							$('#cophoto').val(commodities[i].cophoto);
							$('#conum').val(commodities[i].conum);
							$('#coprice').val(commodities[i].coprice);
							$('#uid').val(commodities[i].uid);
						}
					}
						});
				//获取商品类型
				$.ajax({
					type:"post",
					url:"../../commdidties/findcoclass",
					contentType:"application/json;charset=utf-8",
					success:function(coclass){
						for(var i=0;i<coclass.length;i++ ){
							$('#claname')
								.append("<option value="+coclass[i].claname+">"+coclass[i].claname+"</option>");
						}
					}
				}); 	
	   });
	</script>
</head>
<body>
<form action="index.html" method="post" class="definewidth m20">
<input type="hidden" name="id" value="{$menu.id}" />
<table class="table table-bordered table-hover m10">
    <tr>
        <td width="10%" class="tableleft">类型</td>
        <td>
            <select name="claname" id="claname">
            <option value="--">--</option>
             </select>
        </td>
    </tr>
    <tr>
        <td class="tableleft">商品号</td>
        <td><input type="text" name="coid" id="coid"/></td>
    </tr>
    <tr>
        <td class="tableleft">商品名</td>
        <td><input type="text" name="coname" id="coname"/></td>
    </tr>
    <tr>
        <td class="tableleft">商品样式</td>
        <td><input type="text" name="cophoto" id="cophoto"/></td>
    </tr>
    <tr>
        <td class="tableleft">商品数量</td>
        <td><input type="text" name="conum" id="conum"/></td>
    </tr>
    <tr>
        <td class="tableleft">商品价格</td>
        <td><input type="text" name="coprice" id="coprice"/></td>
    </tr>
    <tr>
        <td class="tableleft">商品归属</td>
        <td><input type="text" name="uid" id="uid"/></td>
    </tr>
    <tr>
        <td class="tableleft">状态</td>
        <td>
            <input type="radio" name="status" value="0" disabled="disabled"/> 启用
            <input type="radio" name="status" value="1" disabled="disabled"/> 禁用
        </td>
    </tr>
    <tr>
        <td class="tableleft"></td>
        <td>
            <button type="button" class="btn btn-primary" type="button" id="commoditiesSave">保存</button> &nbsp;&nbsp;
            <button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
        </td>
    </tr>
</table>
</form>
</body>
</html>